package com.yinp.tools.utils;

import android.content.Context;
import android.content.res.Resources;

public class ToolsUtils {
    /**
     * 获取屏幕高度的px
     *
     * @return
     */
    public static float getHeightPixels() {

        return Resources.getSystem().getDisplayMetrics().heightPixels;
    }

    /**
     * 获取屏幕宽度的px
     *
     * @return
     */
    public static float getWidthPixels() {

        return Resources.getSystem().getDisplayMetrics().widthPixels;
    }

    /**
     * dp转px
     *
     * @return
     */
    public static float dpToPx(float value) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return scale * value + 0.5f;
    }

    /**
     * px转dp
     *
     * @return
     */
    public static float pxToDp(float value) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return value / scale + 0.5f;
    }
}
